package com.qianfeng.smartdevice.controller;


import com.qianfeng.smartdevice.dto.R;
import com.qianfeng.smartdevice.pojo.Menus;
import com.qianfeng.smartdevice.service.IMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/menus")
public class MenuController {

    @Autowired
    private IMenuService menuService;


    @GetMapping("/menus")
    public R getMenus(){
        //通过 service 调用 mapper 最终返回所有的菜单
        List<Menus> menusList = menuService.findAllMenus();
        //int i = 1/0
        return R.setOk(menusList);//设置返回结果,通过统一的返回格式进行返回
    }
}
